package j02block;

public class Cat {
    String name;
    int legs;
    int eyes;

    //构造代码块
    {
        //通用属性属性赋值
        legs = 4;
        System.out.println("构造代码块1");

        System.out.println(Cat.s1);
    }
    {
        //通用属性属性赋值
        eyes = 2;
        System.out.println("构造代码块2");
    }

    static int s1;
    static int s2;
    //静态代码块,使用此类，会执行
    static {
        s1 = 4;
        System.out.println("static1");
//        System.out.println("eyes = " + eyes);
    }
    static {
        s2 = 2;
        System.out.println("static2");
    }

    public Cat(String name) {
        this.name = name;
    }

    public Cat() {
        System.out.println("cat无参构造");
    }
}

class CatTest{
    public static void main(String[] args) {
//        new Cat();
//        new Cat("加菲猫");
        System.out.println("Cat.s1 = " + Cat.s1);
        System.out.println("Cat.s2 = " + Cat.s2);
    }
}
